ReadVariables

Syntax: @ReadVariables filename[, errornum]

The ReadVariables command opens and reads an ASCII format text file, which has typically been created by the WriteVariables command. This can be used to read variables back into XpertRule. The list of variable names is stored in the file. The filename can be a string literal or a string variable.

An optional errornum numeric variable can be used, which will return one of these values:

·-1 The filename was not found or cannot be opened.

·0 The read has been successful.

·>0 The line number in which an error occurred. This could be caused by a variety of faults, including:

-A mismatch between the value encountered and the possible string values of a given attribute variable.

-String data found when numeric data was expected, or other similar data inconsistency.

-Mismatch between the number of variables expected and the number of variables in the file.

The FOpen, FRead and FWrite file commands are more powerful. However, these more basic ReadVariables and WriteVariables commands are often easier for simple file access.

The text file must be in the format of:

variablename, value

variablename, value

variablename, value

etc.

String and date values must be enclosed in double quotes. By default XpertRule expects the text file to be resident in the same data sub directory as your current application.

If you are using external file references you may need to use explicit path names, or use the @XRApath command, for WindowsNT, 2000 or XP.

Example

@ReadVariables 'C:\Mydir\Myfile'

where the text file Myfile in the sub directory Mydir on drive C contains the following four lines of text:

Grade,"Director"

Cost,99.30

Order,"20/12/90"

Tempval,"Hello there!"

This example shows where the list attribute Grade obtains the value Director. The numeric attribute Cost obtains the value 99.30. The date attribute Order obtains the value 20/12/90 and the string variable Tempval obtains the value Hello there. Each line must be separated by CR/LF (i.e. a line break).